<!--
 * @Author: 白川 杏 baiyufeisteam@163.com
 * @Date: 2023-04-19 08:23:23
 * @LastEditors: 白川 杏 baiyufeisteam@163.com
 * @LastEditTime: 2023-06-02 15:54:45
 * @FilePath: \backend\vueproject\src\components\User.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div id="mainpart">
        <div>
            <span id="spanpart">商品评论图片</span>
            <el-divider content-position="left">您具有一定的操作权限</el-divider>
        </div>
        <!-- 
        <div>
            <span id="spanlittlepart">查询</span>
            <el-divider>
                <el-icon><star-filled /></el-icon>
            </el-divider>
        </div> -->

        <!-- 查询 -->
        <!-- <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="comimg_id">
                <el-input v-model="checkformInline.comimg_id" placeholder="comimg_id"></el-input>
            </el-form-item>
            <el-form-item label="comment_id">
                <el-input v-model="checkformInline.comment_id" placeholder="comment_id"></el-input>
            </el-form-item>
        </el-form> -->

        <!-- 查询结果展示 -->
        <!-- <div v-for="item in tableData" :key=item>
            <el-descriptions :border="true" title="commentimg"
                v-if="(item.comimg_id == checkformInline.comimg_id) || (item.comment_id == checkformInline.comment_id)">
                <el-descriptions-item label="comimg_id">{{ item.comimg_id }}</el-descriptions-item>
                <el-descriptions-item label="comment_id">{{ item.comment_id }}</el-descriptions-item>
                <el-descriptions-item label="imgs" width="200">
                    <div style="display: flex; align-items: center">
                        <el-image :src="item.imgs" />
                    </div>
                </el-descriptions-item>
            </el-descriptions>
        </div> -->

        <div>
            <span id="spanlittlepart">所有数据·点击图片可预览</span>
            <el-divider>
                <el-icon><star-filled /></el-icon>
            </el-divider>
        </div>

        <!-- 展示表格 -->
        <el-table :data="tableData" style="width: 100%" highlight-current-row="true" :scrollbar-always-on="true">
            <el-table-column prop="comimg_id" label="comimg_id" width="" />
            <el-table-column prop="comment_id" label="comment_id" width="" />
            <el-table-column label="imgs" width="200">
                <template #default="scope">
                    <div style="display: flex; align-items: center">
                        <el-image
                            style="width: 100px; height: 100px; padding-left: -30px;margin-left: -30px; overflow: visible;"
                            :src="tableimgList[scope.$index]" :preview-src-list="tableimgList" :preview-teleported="true"
                            :initial-index="scope.$index" />
                    </div>
                </template>
            </el-table-column>
        </el-table>

        <el-pagination background layout="prev, pager, next" :current-page="page" @update:current-page="handleCurrentChange"
            :total="total" :page-size="size" style="bottom: 0; text-align: center;margin-left: 45%;margin-top: 5px;" />

    </div>
</template>
<script setup>
import {
    Guide,
    PictureFilled,
    User,
    HomeFilled,
    ChatLineSquare,
    Apple,
    Document,
    List,
    Tools,
    ShoppingCart,
    CollectionTag,
    Finished,
    InfoFilled,
    Cherry,
    Goods,
    Sell,
    ShoppingCartFull,
    Van,
    Sunrise,
    StarFilled,
    EditPen,
    Edit,
    Promotion,
    Grape,
    Pear,
} from '@element-plus/icons-vue';
import dayjs from 'dayjs';
import { ElMessage } from 'element-plus';
import axios from 'axios';
const formLabelWidth = '140px';

</script>
<script>

export default {
    data() {
        return {
            baseURL: 'http://localhost:8080',
            formInline: {
                comimg_id: 0,
                comment_id: 0,
                imgs: '',
            },
            checkformInline: {
                comimg_id: 0,
                comment_id: 0,
                imgs: '',
            },
            dialogFormVisible: false,
            showSearch: false,
            tableData: [],
            tableDataStore: [],
            tableimgList: [],
            tableimg: '',
            user: {
                comimg_id: 0,
                comment_id: 0,
                imgs: '',
            },
            form: {
                comimg_id: 0,
                comment_id: 0,
                imgs: '',
            },
            addform: {
                comimg_id: 0,
                comment_id: 0,
                imgs: '',
            },
            searchForm: [],
            page: 1, // 当前页码
            total: 0, // 总条数
            size: 10, // 每页的数据条数
            reallyTable: [],
            selData: [],
        }
    },
    methods: {
        async handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.page = val
            this.tableData = this.selData.slice(
                (this.page - 1) * this.size,
                this.page * this.size
            );
            // this.currentPage = val;
            const data = { 'page': val }
            // await this.onload(data)
        },
    },
    mounted() {
        //页面加载完成后，将数据库内的内容赋给定义的data变量
        axios({
            method: 'post',
            url: 'http://localhost:8080/goodscomment/commentimgbackend',
            withCredentials: true,
        }).then(res => {
            this.tableData = res.data.data;
            this.tableDataStore = res.data.data;
            console.log(res.data.data);
            this.tableData = res.data.data.slice(
                (this.page - 1) * this.size,
                this.page * this.size
            );
            this.total = res.data.data.length;
            this.selData = res.data.data;
            for (var i = 0; i < res.data.data.length; i++) {
                this.tableimgList.push(res.data.data[i].imgs
                );
            }
            //console.log("tableimglist:" + this.tableimgList);
            this.tableimg = this.tableimgList[0];
            console.log("tableimg：-------->" + this.tableimg);
        })
    }
}
</script>
<style scoped>
#sidepart {
    width: 100%;
    position: absolute;
    top: 5px;
    font-family: '华文中宋';
}

#mainpart {
    width: 100%;
    position: absolute;
    top: 20px;
    /* left: 260px; */
    font-family: '华文中宋';
}

#spanpart {
    font-size: 30px;
    font-family: '华文中宋';
}

/* dialog */
.el-button--text {
    margin-right: 15px;
}

.el-select {
    width: 300px;
}

.el-input {
    width: 300px;
}

.dialog-footer button:first-child {
    margin-right: 10px;
}

#spanlittlepart {
    font-size: 15px;
    color: cadetblue;
    font-family: '华文中宋';
}
</style>